
export const scientificToNumber = function (inputNumber) {
  if (isNaN(inputNumber)) {
    return inputNumber
  }
  // 获取整数部分
  const intPart = Math.trunc(inputNumber)
  // 整数部分处理，增加,
  const intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,')
  // 预定义小数部分
  let floatPart = '.00'
  // 将数据分割为小数部分和整数部分
  const newArr = inputNumber.toString().split('.')
  if (newArr.length === 2) { // 有小数部分
    floatPart = newArr[1].toString() // 取得小数部分
    return intPartFormat + '.' + floatPart
  }
  return intPartFormat + floatPart
}

export const desensitizedName = function (name) {
  if (name) {
    let center = name.substring(1, name.length - 1)
    name = name.substring(0, 1) + "*".padStart(center.length, '*') + name.substring(name.length - 1, name.length)
  }
  return name
}

export const desensitizedPhone = function (tel) {
  if (tel) {
    tel = tel.substring(0, 3) + "****" + tel.substring(tel.length - 4, tel.length)
  }
  return tel
}


export const desensitizedPaperCode = function (paperCode) {
  if (paperCode) {
    paperCode = paperCode.replace(/^(.{3})(?:\d+)(.{4})$/, "$1" + "*".padStart(paperCode.length - 7, '*') + "$2")
  }
  return tel
}

export const formatterStatisNumber = function (value) {
  if (value) {
    var num = value.toString()
    var len = num.length
    if (len <= 3) {
      return num
    }
    var res = len % 3
    return res > 0 ?
      num.slice(0, res) + "," + num.slice(res, len).match(/\d{3}/g).join(",")
      : num.slice(res, len).match(/\d{3}/g).join(",")
  }
  return 0
}
